var path = require("path");
var HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
  // 入口
  entry: {
    main: "./main.js"
  },
  //输出
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bundle.js"
  },
  //loader 
  module: {
    rules: [
      // es6转es5 的babel-loader 
      {
        test: /\.m?js$/, //匹配所有的.js文件 
        exclude: /(node_modules|bower_components)/,//不匹配 node_modules中的文件
        use: {
          loader: "babel-loader",
          options: {
            presets: ['@babel/preset-env']
          }
        }
      },
      // 让webpack能识别 css 
      {
        test: /\.css$/i,
        use: ["style-loader", "css-loader"]
      }
    ]
  },
  //模式  development开发模式  生产模式 production
  mode: "development",
  //插件
  plugins: [
    new HtmlWebpackPlugin({
      filename: "./index.html"
    })
  ]
}